﻿package yii.db.schema{

	import yii.db.*;
	import phpas3.*;

	public class CDbCriteria{



	const PARAM_PREFIX:String=':ycp';
	public static var paramCount:int =0;
	public var select:*='*';
	public var distinct:Boolean =false;
	public var condition:String='';
	public var params:Array = new Array();
	public var limit:int =-1;
	public var offset:int =-1;
	public var order:String='';
	public var group:String='';
	public var join:String='';
	public var having:String='';
	public var with_obj:*;
	public var alias:String="";
	public var together:Boolean ;
	public var index:String;
	public var scopes:*;






		public function CDbCriteria( data:Array=null ){
			if( data===null ){
				data = new Array();
			}
			for( var index in data ){
				if( this[index] ){
					this[index] = data[index];
				}
			}
		}









	/**
	 * Appends a condition to the existing {@link condition}+
	 * The new condition and the existing condition will be concatenated via the specified operator
	 * which defaults to 'AND'+
	 * The new condition can also be an array+ In this case, all elements in the array
	 * will be concatenated together via the operator+
	 * This method handles the case when the existing condition is empty+
	 * After calling this method, the {@link condition} property will be modified+
	 * @param mixed $condition the new condition+ It can be either a string or an array of strings+
	 * @param string $operator the operator to join different conditions+ Defaults to 'AND'+
	 * @return CDbCriteria the criteria object itself
	 * @since 1+0+9
	 */
	public function addCondition( $condition:*, $operator:String='AND'):CDbCriteria{
		if(is_array($condition)){
			if( $condition.length==0 ){
				return this;
			}
			$condition = '('+ implode(') '+ $operator +' (', $condition) +')';
		}
		if( this.condition === '' ){
			this.condition = $condition;
		} else {
			this.condition = '('+ this.condition +') '+ $operator +' ('+ $condition +')';
		}
		return this;
	}

































	}
}